<!-- components/modules/SceneGraphPanel.vue -->
<template>
  <div class="scene-graph-panel">
    <div class="response-content">
      <!-- 显示场景图 -->
      <GraphVisualization ref="graphViz" :graph-data="graphData" @open-modal="openModal" />
    </div>

    <!-- 模态框 -->
    <div v-if="isModalOpen" class="modal-overlay" @click="closeModal">
      <div class="modal-content" @click.stop>
        <GraphVisualization :graph-data="graphData" class="modal-graph" />
        <button class="close-button" @click="closeModal">X</button>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref, computed, watch } from 'vue'
import GraphVisualization from './GraphVisualization.vue' // 引入新的组件

const props = defineProps({
  graphData: {
    // 接收父组件传入的完整场景图数据
    type: Object,
    default: () => ({ nodes: [], edges: [] }),
  },
})

const isModalOpen = ref(false)

// 打开模态框
const openModal = () => {
  isModalOpen.value = true
}

// 关闭模态框
const closeModal = () => {
  isModalOpen.value = false
}
</script>

<style scoped>
/* 整体容器 */
.scene-graph-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: none;

}

/* 内容区域 */
.response-content {
  flex: 1;
  overflow: hidden;
  padding: 0px;
  background-color: #2e3b55; /* 深色背景突出图表 */
  background-color: #ffffff;
  border-radius: 4px;
  box-shadow: none;

  /* border: 1px solid #e0e0e0; */
}


/* 模态框样式 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  position: relative;
  width: 80vw;
  height: 80vh;
  background-color: #ffffff;
  border-radius: 8px;
  padding: 1px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.modal-graph {
  width: 100%;
  height: 100%;
}

.close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 24px;
  color: #000000;
  cursor: pointer;
  transition: color 0.2s ease;
}

.close-button:hover {
  color: #ff4444;
}
</style>
